import * as echarts from "echarts";
import {useEffect, useRef} from "react";

const Bar = ({title, xData, yData, style}) => {
    const domRef = useRef()
    const chartInit = () => {
        const myChart = echarts.init(domRef.current)
        myChart.setOption({
            title: {
                text: title
            },
            tooltip: {},
            xAxis: {
                data: xData
            },
            yAxis: {},
            series: [
                {
                    name: '热度',
                    type: 'bar',
                    data: yData
                }
            ]
        });
    }
    useEffect(() => {
        chartInit()
    }, [])
    return <div className={'bar'} ref={domRef} style={style}></div>
}

export default Bar